import requests
from common.Authorization_date import ihrmAuthorization




# 创建 封装部门管理接口实例
class DepartManagerApi:
    # 部门添加接口
    @classmethod
    def depart_insert(cls):
        herderJson = {"Content-Type":"application/json","Authorization":ihrmAuthorization()}
        jsonData = {"name": "超级管理", "code": "999999"}
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/company/department",
                             headers=herderJson,
                             json=jsonData)

        return resp

    # 部门修改
    @classmethod
    def depart_update(cls,depart_id):
        herderJson = {"Content-Type": "application/json", "Authorization": ihrmAuthorization()}
        jsonData = {"name": "垃圾部门", "code": "444444"}
        resp = requests.put(url="http://ihrm2-test.itheima.net/api/company/department/"+depart_id,
                             headers=herderJson,
                             json=jsonData)
        return resp

    # 部门查询
    @classmethod
    def depart_select(cls,depart_id):
        herderJson = {"Content-Type": "application/json", "Authorization": ihrmAuthorization()}
        resp = requests.get(url="http://ihrm2-test.itheima.net/api/company/department/" + depart_id,
                            headers=herderJson)
        return resp
    # 部门删除
    @classmethod
    def depart_del(cls,depart_id):
        herderJson = {"Content-Type": "application/json", "Authorization": ihrmAuthorization()}
        resp = requests.delete(url="http://ihrm2-test.itheima.net/api/company/department/" + depart_id,
                            headers=herderJson)
        return resp